﻿using System;
using FineUI;
using SDLITS.Common;
using SDLITS.Model;

namespace SDLITS.Web.Driver
{
    public partial class DriverViewManage : CommonBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GroupPanel1.Hidden = true;
                GroupPanel2.Hidden = true;
                GroupPanel3.Hidden = true;
                GroupPanel4.Hidden = true;
            }
        }

        protected void txtMemCardNo_TextChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtMemCardNo.Text))
            {
                V_MemCardInfoType card = SDDbSession.Default.From<V_MemCardInfoType>().Where(V_MemCardInfoType._.MemCardNo == txtMemCardNo.Text.Trim()).ToFirst();
                if (card != null)
                {
                    GroupPanel1.Hidden = false;
                    GroupPanel2.Hidden = false;
                    GroupPanel3.Hidden = false;
                    GroupPanel4.Hidden = false;

                    #region 1
                    txt_sfz.Text = card.IDNumber;
                    txt_name.Text = card.Name;
                    txt_addr.Text = card.IDAddress;
                    txt_sex.Text = card.Sex.ToString().ToLower() == "false" ? "女" : "男";
                    txt_birth.Text = card.Birthday.ToString();
                    txt_phone.Text = card.Cell;
                    txt_tel.Text = card.Phone;
                    txt_note1.Text = card.Custom1;
                    txt_note2.Text = card.Custom2;
                    img1.ImageUrl = string.Format("{0}{1}.bmp", @"/Img/IDShot/", card.IDNumber);
                    Image1.ImageUrl = string.Format("{0}{1}.bmp", @"/Img/FingerShot/", card.IDNumber);
                    Image2.ImageUrl = string.Format("{0}{1}.bmp", @"/Img/CamShot/", card.IDNumber);
                    #endregion
                    #region 2
                    txt_start.Text = card.StartDate.ToString();
                    txt_end.Text = card.ExpireDate.ToString();
                    txt_cash.Text = card.LeftCash.ToString();
                    #endregion
                    #region 3
                    txt_drivername.Text = card.DLName;
                    rblsex.SelectedValue = string.IsNullOrEmpty(card.DLSex.ToString()) ? "1" : (Boolean.Parse(card.DLSex.ToString()) ? "1" : "2");
                    txt_cardno.Text = card.DLNumber;
                    txt_cardaddr.Text = card.DLAddress;
                    #endregion
                    #region 4
                    txt_carno.Text = card.CarNo;
                    txt_fdj.Text = card.CarEnginNo;
                    txt_bs.Text = card.CarIDNo;
                    txt_cz.Text = card.CarOwnerName;
                    txt_czdz.Text = card.CarOwnerAddr;
                    txt_gchm.Text = card.GCarNo;
                    txt_gcbs.Text = card.GCarIDNo;
                    #endregion
                }
                else
                {
                    Alert.Show("没有该卡号信息");
                }
            }
        }
    }
}